
import com.wzy.peopleManagement.model.LoginModel;

import flash.net.SharedObject;

private const min_width:int = 350; 
private const min_height:int = 200; 

public function goLogin() : void {
  	var mySequence:Sequence = new Sequence(); 
 	var gate:Gate = new Gate(login); 
  	gate.siblings = [ mainPanel ]; 
  	gate.direction = DistortionConstants.LEFT;     
  	gate.smooth = true; 
  	gate.distortion = 10; 
  	gate.mode = Gate.OPEN; 
  	gate.duration = 1000; 
  	mySequence.addChild(gate); 
 
  	var parallel:Parallel = new Parallel(); 
  	var resize:Resize = new Resize(); 
  	resize.target = loginStack; 
  	resize.widthTo = 950; 
  	resize.heightTo = 638; 
  	resize.duration = 1000; 
  	parallel.addChild(resize); 
   
  	resize = new Resize(); 
  	resize.target = mainPanel; 
  	resize.widthTo = 950; 
  	resize.heightTo = 638; 
  	resize.duration = 1000; 
  	parallel.addChild(resize); 
  	
  	var move : Move = new Move();
  	move.target     = this;
  	move.yTo        = 5;    
  	move.duration   = 1000;  
  	parallel.addChild(move);        
  	mySequence.addChild(parallel);  
   
    mySequence.play(); 
    mySequence.addEventListener(EffectEvent.EFFECT_END,loginEndEffect);
} 
public function loginEndEffect(event : EffectEvent) : void {
	if(LoginModel.getInstance().userType == "admin") {
		mainViewStack.selectedChild = adminMainView;
	}
	if(LoginModel.getInstance().userType == "user") {
		mainViewStack.selectedChild = userMainView;
	}
	this.userName.text = "";
	this.userPass.text = "";
}
public function logOff() : void {
    var mySequence:Sequence = new Sequence(); 
    var gate:Gate = new Gate(mainPanel); 
    gate.siblings = [ login ]; 
    gate.direction = DistortionConstants.LEFT;     
    gate.smooth = true; 
    gate.distortion = 10; 
    gate.mode = Gate.CLOSE; 
    gate.duration = 1000; 
    mySequence.addChild(gate); 
 
    var parallel:Parallel = new Parallel(); 
    var resize:Resize = new Resize(); 
    resize.target = loginStack; 
    resize.widthTo = min_width; 
    resize.heightTo = min_height; 
    resize.duration = 1000; 
    parallel.addChild(resize); 
   
    resize = new Resize(); 
    resize.target = mainPanel; 
    resize.widthTo = min_width; 
    resize.heightTo = min_height; 
    resize.duration = 1000; 
    parallel.addChild(resize);              
    mySequence.addChild(parallel);  
   
    mySequence.play(); 
    mySequence.addEventListener(EffectEvent.EFFECT_END,logOffEffect);
} 
private function logOffEffect(event : EffectEvent) : void {
   loginStack.selectedChild = login; 
   this.mainViewStack.selectedChild = defaultMainView;
   var so:SharedObject = SharedObject.getLocal("validate","/");
   so.clear();
   so.flush();

}